/******************************************************************************
Project    : Real time rtsp server library base on live555
*******************************************************************************
File Name    :  <Mp2TsRTimeServerMediaSubsession.h>:  mp2ts real time SMSS head file
Module Name  :  
Description  :  None
History      :
 No.   Ver.     Date        Designed by  Comment
-----+--------+----------+------------+---------------------------------------
 001   0.00.01  06/04/2015  <3G@LIURENHUA>   <mp2ts real time SMSS head file>
*******************************************************************************/
#ifndef _MP2TS_RTIME_SERVER_MEDIA_SUBSESSION_H
#define _MP2TS_RTIME_SERVER_MEDIA_SUBSESSION_H

#include <liveMedia.hh>
#ifdef LOCAL_SOCK_INPUT
#include <LocalUdpSocket.h>
#endif /* LOCAL_SOCK_INPUT */

#include "RealTimeRtspServer_common.h"
/******************************************************************************
  class declaration
 ******************************************************************************/
class Mp2TsRTimeServerMediaSubsession : public OnDemandServerMediaSubsession
{
public:
	/* Create new server media session object */
	static Mp2TsRTimeServerMediaSubsession * createNew(
							UsageEnvironment & env,
#ifdef LOCAL_SOCK_INPUT
							const char  *pcIdentity = NULL,
							const u_int32_t unSBufSize = 0, 
							const u_int32_t unRBufSize = 0
#else
							queue_t *pstQue = NULL
#endif /* LOCAL_SOCK_INPUT */
							);
protected:
	Mp2TsRTimeServerMediaSubsession(
							UsageEnvironment & env,
#ifdef LOCAL_SOCK_INPUT
							const char  *pcIdentity,
							const u_int32_t unSBufSize, 
							const u_int32_t unRBufSize
#else
							queue_t *pstQue
#endif /* LOCAL_SOCK_INPUT */
							);
	virtual ~Mp2TsRTimeServerMediaSubsession(void){
	};

private:
	/* "estBitrate" is the stream's estimated bitrate, in kbps */
	virtual FramedSource * createNewStreamSource(
		unsigned clientSessionId, unsigned & estBitrate); 
	virtual RTPSink * createNewRTPSink(
		Groupsock * rtpGroupsock, 
		unsigned char rtpPayloadTypeIfDynamic, 
		FramedSource * inputSource);
	
private:
#ifdef LOCAL_SOCK_INPUT
	/* Save local socket identity */
	char m_cIdentity[LSOCK_ID_LENGTH];
	
	/* Local socket send buffer size */
	u_int32_t m_unSBufSize;
	/* Local socket receive buffer size */
	u_int32_t m_unRBufSize;
#else
	queue_t *m_que;
#endif /* LOCAL_SOCK_INPUT */
};
#endif /* _MP2TS_RTIME_SERVER_MEDIA_SUBSESSION_H */
